$('#login-btn').on('click', function () {
  var username = $('#input-username').val();
  var password = $('#input-password').val();

  $.ajax({
    url: '/users/login',
    method: 'POST',
    data: {
      username,
      password
    }
  })
    .done((res) => {
      console.log('登录请求成功：', res);
      if (res.code == '200') {
        location.href = '/views/home.html'
      } else {
        $('#input-username').val('');
        $('#input-password').val('');
        layer.msg(res.msg);
      }
    })
    .fail(err => {
      console.log('登陆请求失败：', err);
      layer.msg(err.msg);
    });
});